﻿///////////////////////////////////////////////////////
//
// XDesigner.ORM 
//
// autohr : yuans
//
// date: 2011-2-23
//
// email  : yyf9989@hotmail.com
// 
//
///////////////////////////////////////////////////////

using System;
using System.Text;
using System.Data ;

namespace XDesigner.ORM
{
    public class ORMContext
    {
        public ORMContext( ORMEngine work )
        {
            if (work != null)
            {
                _Engine = work;
                _ParameterStyle = work.Config.ParameterStyle;
                _Command.Engine = work;
            }
            _Buffer.IsGlobal = false;
        }

        private ORMInstanceBuffer _Buffer = new ORMInstanceBuffer();

        public ORMInstanceBuffer Buffer
        {
            get { return _Buffer; }
            set { _Buffer = value; }
        }

        private ORMDBCommand _Command = new ORMDBCommand();

        public ORMDBCommand Command
        {
            get
            {
                return _Command; 
            }
            set
            {
                _Command = value;
                if (_Command != null)
                {
                    _Command.Engine = this._Engine;
                }
            }
        }

        private ParameterStyle _ParameterStyle = ParameterStyle.SQLServerStyle;

        public ParameterStyle ParameterStyle
        {
            get { return _ParameterStyle; }
            set { _ParameterStyle = value; }
        }

        private ORMEngine _Engine = null;

        public ORMEngine Engine
        {
            get
            {
                return _Engine; 
            }
            set
            {
                _Engine = value;
                _Command.Engine = value;
            }
        }

        internal bool ForGenerateCode = false;
    }
}
